import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/modules/application/more_apply/more_apply_controller.dart';

/// 更多模块列表显示
class MoreApplyPage extends StatelessWidget {
  MoreApplyPage({super.key});

  final controller = Get.put(MoreApplyController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Scaffold(
            appBar: CustomAppBar(titleText: '菜单列表'),
            body: Container(
              padding: EdgeInsets.only(top: 10.w),
              alignment: Alignment.topCenter,
              color: const Color(0xffF5F5F6),
              child: Container(
                alignment: Alignment.topCenter,
                padding: EdgeInsets.symmetric(vertical: 20.w),
                color: Colors.white,
                child: _getApplicationModuleView(),
              ),
            ),
          );
        });
  }

  /// 获取应用模块信息
  Widget _getApplicationModuleView() {
    return SingleChildScrollView(
      child: Wrap(
        spacing: 10.w, // 主轴(水平)方向间距
        runSpacing: 24.w, // 纵轴（垂直）方向间距
        // alignment: WrapAlignment.start, //沿主轴方向居中
        direction: Axis.horizontal,
        children: controller.allApplyList.map<Widget>((item) {
          return SizedBox(
              width: 65.w,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  SvgPicture.asset(
                    item.iconPath,
                    height: 28.w,
                    width: 28.w,
                  ),
                  AppGaps.vGap8,
                  Text(
                    item.name,
                    style: TextStyle(
                      fontSize: 10.sp,
                      fontWeight: FontWeight.w400,
                      color: const Color(0xff646E79),
                    ),
                  ),
                ],
              )).clickOnce(() {
            controller.toModulePage(item);
          });
        }).toList(),
      ),
    );
  }
}
